import { NEWLY_ADDED_GOOD, ADDONE_TENTH_GOOD, EDIT_SEARCH_HISTORY } from './mutations.type'


export default {
  buyCart(context, payload) {
    const isExistence = JSON.stringify(Object.values(context.state.goods)).includes(payload.food_id)
    if (isExistence) {
      context.commit(ADDONE_TENTH_GOOD, payload)
    } else {
      context.commit(NEWLY_ADDED_GOOD, payload)
    }
  },
  searchHistory(context, payload) {
    if (context.state.searchHistory.includes(payload)) {
      return
    }
    context.commit(EDIT_SEARCH_HISTORY, payload)
  }
}